package com.tnovoselec.android.lbs.map;


import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.google.android.maps.MapView;

public class CustomZoomMapView extends MapView {

	private long lastTouchTime = -1;
	private boolean enableDoubleTapZoom = true;

	public CustomZoomMapView(Context context, AttributeSet attrs) {
		this(context, attrs, true);
	}
	public CustomZoomMapView(Context context, AttributeSet attrs, boolean enableDoubleTapZoom) {
		super(context, attrs);
		this.enableDoubleTapZoom = enableDoubleTapZoom;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		if (ev.getAction() == MotionEvent.ACTION_DOWN && enableDoubleTapZoom) {
			long thisTime = System.currentTimeMillis();
			if (thisTime - lastTouchTime < 250) {
				getController().zoomInFixing((int) ev.getX(), (int) ev.getY());
				lastTouchTime = -1;
			} else {
				lastTouchTime = thisTime;
			}
		}

		return super.onInterceptTouchEvent(ev);
	}
	
	
}